import request from "./request";

const baseURL = '/torrent'

// rpc封装接口
const sengToClient = () => {
  return request.doRequest(`${baseURL}/sengToClient`, {})
};

const infoInClient = (params) => {
  return request.doRequest(`${baseURL}/infoInClient`, {params})
};

const downloadFromClient = (clientid) => {
  return request.doRequest(`${baseURL}/downloadFromClient`, {params:{clientid}})
};

const pushToClient = (data) => {
  return request.doRequest(`${baseURL}/pushToClient`, {method:'POST',data})
};

const linkToLibrary = (params) => {
  return request.doRequest(`${baseURL}/linkToLibrary`, {params})
};

const doLinkToLibrary = (data) => {
  return request.doRequest(`${baseURL}/doLinkToLibrary`, {method:'POST',data})
};

const setLocation = (data) => {
  return request.doRequest(`${baseURL}/setLocation`, {method:'POST',data})
};

const removeTorrent = (data) => {
  return request.doRequest(`${baseURL}/remove`, {method:'POST',data})
};

const doAction = (id, action) => {
  return request.doRequest(`${baseURL}/doAction`, {method:'POST',data:{id,action}})
};


const TorrentApi = {
  sengToClient, infoInClient, downloadFromClient, pushToClient, linkToLibrary, doLinkToLibrary, setLocation, removeTorrent, doAction
};



export default TorrentApi;
